package com.grademaster.controller;

import com.grademaster.common.R;
import com.grademaster.dto.LoginRecordDto;
import com.grademaster.service.LoginRecordsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/loginRecord")
@Api(tags = "登录记录相关接口")
@CrossOrigin(origins = {"http://localhost:8081"}, allowCredentials = "true")
public class LoginRecordController {

    @Autowired
    private LoginRecordsService loginRecordsService;

    @ApiOperation("获取所有登录记录分页信息")
    @GetMapping("/getAllLoginRecordsByPage")
    public R getAllLoginRecordsByPage(LoginRecordDto loginRecordDto) {
        return loginRecordsService.getAllLoginRecordsByPage(loginRecordDto);
    }
    @ApiOperation("导出成绩列表到Excel")
    @GetMapping("/exportExcel")
    public ResponseEntity exportExcel(LoginRecordDto loginRecordDto){
        return loginRecordsService.exportExcel(loginRecordDto);
    }
}
